﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using COMOSOFT.Class;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;

namespace COMOSOFT.JobManagement.Froms
{
    public partial class PopUpApproveStaff : Form
    {
        ClassShare cls = new ClassShare("PopUpApproveStaff");
        int JID,flag;
        public PopUpApproveStaff(int _JID,int _flag)
        {            
            InitializeComponent();
            JID = _JID;
            flag = _flag;
        }

        private void bnt_StaffOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (gridView_ChooseStaff.FocusedRowHandle >= 0)
                {
                    int[] view = gridView_ChooseStaff.GetSelectedRows();
                    string Status = null;
                    if (flag == 0)
                        Status = "Reject";
                    else
                        Status = "Approved";
                    foreach (int item in view)
                    {
                        cls.UpdateData("sp_JobSubmiterUpdate", new string[] { "@JID", "@EID", "@Status", "@Comment", "@flag" }, new object[] { JID, Convert.ToInt32(gridView_ChooseStaff.GetDataRow(item)["EID"]), Status, "", 2 });
                    }
                }
                this.Close();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void PopUpApproveStaff_Load(object sender, EventArgs e)
        {            
            this.employeeTableAdapter1.Fill(this.dataSetOrderManagement.Employee);
            this.sp_JobSubmiterStatusTableAdapter.Fill(this.dataSet_JobManagement.sp_JobSubmiterStatus, JID, ClassShare.Usid, 1);
        }
    }
}
